import { persist } from "zustand/middleware";
import { IBannerType } from "@/api/home";
import create from "zustand";
interface PlayerState {
  popShow: boolean;
  popData: IBannerType | null;
  isPlay: boolean;
  bubbleShow: boolean;
  togglePopShow: (bool: boolean) => void;
  changePopData: (data: IBannerType) => void;
  togglePlay: (bool: boolean) => void;
  toggleBubbleShow: (bool: boolean) => void;
}
export const usePlayerStore = create<PlayerState>()(
  persist(
    (set) => ({
      popShow: false, //播放弹窗显示控制
      popData: null, //播放数据包
      isPlay: false, //播放状态
      bubbleShow: false, //胶囊组件显示控制
      togglePopShow(bool) {
        set({ popShow: bool });
      },
      changePopData(popData) {
        set({ popData });
      },
      togglePlay(isPlay) {
        set({ isPlay });
      },
      toggleBubbleShow(bubbleShow) {
        set({ bubbleShow });
      },
    }),
    {
      name: "music-player-store",
    }
  )
);
